import java.util.Scanner;

public class Main2 {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String s = scanner.nextLine();
        char c = s.charAt(0);
        System.out.println(countChar(line, c));
    }

    public static int countChar(String line,char c){
        int count = 0;
        char[] chars = line.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            if(aChar == c){
                count++;
            }else if("a".charAt(0)<=aChar&&aChar<="z".charAt(0)&&"A".charAt(0)<=c&&c<="Z".charAt(0)){
                if((c+32)==aChar){
                    count++;
                }
            }else if("A".charAt(0)<=aChar&&aChar<="Z".charAt(0)&&"a".charAt(0)<=c&&c<="z".charAt(0)){
                if((c-32)==aChar){
                    count++;
                }
            }
        }
        return count;
    }
}
